<script>

{literal}

$(document).ready( function()
{
    jQuery.fn.filter_set_ok = function ( more )
    {
        $(this).css( 'background-color', '#68f79e' );
        for ( i = 0 ; i < more.length ; i++ )
        {
            $( more[i] ).css( 'background-color', '#68f79e' );
        }
    }

    jQuery.fn.underlying_check_email = function( email )
    {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        if( reg.test( email ) == false ) 
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    jQuery.fn.filter_check_email = function( e )
    {
        var valid = $.fn.underlying_check_email( $(this).val() );
        if ( !valid )
        {
            $(this).css( 'background-color', '#f7689e' );
        }
    }

    jQuery.fn.filter_check_charlimit_keyup = function( limit, obj, e )
    {
        valid = true;
        if ( obj.val().length > limit )
        {
            valid = false;
            e.preventDefault();
        }

        if ( !valid )
        {
            obj.css( 'background-color', '#f7689e' );
        }
    }

    jQuery.fn.filter_check_charlimit_blur = function( limit, obj, e )
    {
        valid = true;
        if ( obj.val().length > limit )
        {
            valid = false;
            e.preventDefault();
        }

        if ( !valid )
        {
            obj.css( 'background-color', '#f7689e' );
        }
    }

    function ReplaceAll( Source, stringToFind, stringToReplace )
    {
        var temp = Source;
        var index = temp.indexOf( stringToFind );
        while( index != -1 )
        {
            temp = temp.replace( stringToFind, stringToReplace );
            index = temp.indexOf( stringToFind );
        }
        return temp;
    }

    jQuery.fn.filter_check_charpool_keyup = function( charpool, obj, e )
    {
        valid = true;

        char_last = obj.val().substring( obj.val().length - 1, obj.val().length );
        if ( charpool.indexOf( char_last ) == -1  )
        {
            //obj.css( 'background-color', '#f7689e' );
            obj.val( ReplaceAll( obj.val(), char_last, '' ) );
            e.preventDefault();
        }
    }

    jQuery.fn.filter_check_minimum_blur = function( minimum, obj, e )
    {
        valid = true;

        var entered_value = parseInt( obj.val(), 10 );
        var minimum_value = parseInt( minimum, 10 );

        if ( minimum_value > entered_value )
        {
            obj.css( 'background-color', '#f7689e' );
        }
    }

    jQuery.fn.filter_check_maximum_blur = function( maximum, obj, e )
    {
        valid = true;

        var entered_value = parseInt( obj.val(), 10 );
        var maximum_value = parseInt( maximum, 10 );

        if ( maximum_value < entered_value )
        {
            obj.css( 'background-color', '#f7689e' );
        }
    }

    jQuery.fn.filter_check_minimum_date_blur = function( minimum_date, obj, e )
    {
        valid = true;


        if ( maximum_value < entered_value )
        {
            obj.css( 'background-color', '#f7689e' );
        }
    }

    jQuery.fn.filter_minimum_hour_minute = function( minimum_date, date_obj, minimum_hour, hour_obj, minimum_minute, minute_obj )
    {
        valid = true;

        if ( date_obj.val() == minimum_date )
        {
            if ( hour_obj.val() == minimum_hour )
            {
                if ( minute_obj.val() < minimum_minute )
                {
                    minute_obj.css( 'background-color', '#f7689e' );
                    //hour_obj.css( 'background-color', '#f7689e' );
                    //date_obj.css( 'background-color', '#f7689e' );
                    return false;
                }
            }
            else
            {
                if ( hour_obj.val() < minimum_hour )
                {
                    //minute_obj.css( 'background-color', '#f7689e' );
                    hour_obj.css( 'background-color', '#f7689e' );
                    //date_obj.css( 'background-color', '#f7689e' );
                    return false;
                }
            }
        }
    }

    jQuery.fn.filter_maximum_hour_minute = function( maximum_date, date_obj, maximum_hour, hour_obj, maximum_minute, minute_obj )
    {
        valid = true;

        if ( date_obj.val() == maximum_date )
        {
            if ( hour_obj.val() == maximum_hour )
            {
                if ( minute_obj.val() > maximum_minute )
                {
                    minute_obj.css( 'background-color', '#f7689e' );
                    //hour_obj.css( 'background-color', '#f7689e' );
                    //date_obj.css( 'background-color', '#f7689e' );
                    return false;
                }
            }
            else
            {
                if ( hour_obj.val() > maximum_hour )
                {
                    //minute_obj.css( 'background-color', '#f7689e' );
                    hour_obj.css( 'background-color', '#f7689e' );
                    //date_obj.css( 'background-color', '#f7689e' );
                    return false;
                }
            }
        }
    }

} );

{/literal}

</script>


<form action="/report/{$report_model}/completed" method="post">
    {foreach from=$questions item=q}
        <div id="question_container_{$q.Question_id}">
            <div id="question_question_{$q.Question_id}">
                {$q.Question}
            </div>
            <input type="hidden" name="question_type_{$q.Question_id}" id="question_type_{$q.Question_id}" value="{$q.id_Question_type}">

            {if $q.id_Question_type == 1}
                {foreach from=$q.Choices item=c name=sc}
                    <input type="radio" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                    <label for="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                        {$c}
                    </label>
                {/foreach}
            {/if}

            {if $q.id_Question_type == 11}
                {foreach from=$q.Choices item=c name=sc}
                    <input type="radio" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                    <label for="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                        {$c}
                    </label>
                {/foreach}
                    <input type="radio" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_other">
                    <label for="question_answer_{$q.Question_id}_other">
                        <input type="text" name="question_answer_{$q.Question_id}_other">
                    </label>
            {/if}

            {if $q.id_Question_type == 2}
                {foreach from=$q.Choices item=c name=sc}
                    <input type="checkbox" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                    <label for="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                        {$c}
                    </label>
                {/foreach}
            {/if}

            {if $q.id_Question_type == 21}
                {foreach from=$q.Choices item=c name=sc}
                    <input type="checkbox" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                    <label for="question_answer_{$q.Question_id}_{$smarty.foreach.sc.index}">
                        {$c}
                    </label>
                {/foreach}
                    <input type="checkbox" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}_other">
                    <label for="question_answer_{$q.Question_id}_other">
                        <input type="text" name="question_answer_{$q.Question_id}_other">
                    </label>
            {/if}

            {if $q.id_Question_type == 3}
                <input type="text" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}">
            {/if}

            {if $q.id_Question_type == 4}
                <input type="text" name="question_answer_{$q.Question_id}" id="question_answer_{$q.Question_id}">
                <script>
                    $(document).ready( function()
                    {
                        $('#question_answer_{$q.Question_id}').numeric({ allow: '.' });
                    } );

                </script>
            {/if}

            {if $q.id_Question_type == 5}
                <div>
                <input type="text" id="question_answer_date_start_{$q.Question_id}" name="question_answer_date_start">
                <select name="question_answer_date_start_hour_{$q.Question_id}" id="question_answer_date_start_hour_{$q.Question_id}">
                    <option value="00">00</option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08">08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                </select>
                <select name="question_answer_date_start_minute_{$q.Question_id}" id="question_answer_date_start_minute_{$q.Question_id}">
                    <option value="00">00</option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08">08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                    <option value="24">24</option>
                    <option value="25">25</option>
                    <option value="26">26</option>
                    <option value="27">27</option>
                    <option value="28">28</option>
                    <option value="29">29</option>
                    <option value="30">30</option>
                    <option value="31">31</option>
                    <option value="32">32</option>
                    <option value="33">33</option>
                    <option value="34">34</option>
                    <option value="35">35</option>
                    <option value="36">36</option>
                    <option value="37">37</option>
                    <option value="38">38</option>
                    <option value="39">39</option>
                    <option value="40">40</option>
                    <option value="41">41</option>
                    <option value="42">42</option>
                    <option value="43">43</option>
                    <option value="44">44</option>
                    <option value="45">45</option>
                    <option value="46">46</option>
                    <option value="47">47</option>
                    <option value="48">48</option>
                    <option value="49">49</option>
                    <option value="50">50</option>
                    <option value="51">51</option>
                    <option value="52">52</option>
                    <option value="53">53</option>
                    <option value="54">54</option>
                    <option value="55">55</option>
                    <option value="56">56</option>
                    <option value="57">57</option>
                    <option value="58">58</option>
                    <option value="59">59</option>
                </select>
                -
                <input type="text" id="question_answer_date_end_{$q.Question_id}" name="question_answer_date_end_{$q.Question_id}">
                <select name="question_answer_date_end_hour_{$q.Question_id}" id="question_answer_date_end_hour_{$q.Question_id}">
                    <option value="00">00</option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08">08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                </select>
                <select name="question_answer_date_end_minute_{$q.Question_id}" id="question_answer_date_end_minute_{$q.Question_id}">
                    <option value="00">00</option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08">08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                    <option value="24">24</option>
                    <option value="25">25</option>
                    <option value="26">26</option>
                    <option value="27">27</option>
                    <option value="28">28</option>
                    <option value="29">29</option>
                    <option value="30">30</option>
                    <option value="31">31</option>
                    <option value="32">32</option>
                    <option value="33">33</option>
                    <option value="34">34</option>
                    <option value="35">35</option>
                    <option value="36">36</option>
                    <option value="37">37</option>
                    <option value="38">38</option>
                    <option value="39">39</option>
                    <option value="40">40</option>
                    <option value="41">41</option>
                    <option value="42">42</option>
                    <option value="43">43</option>
                    <option value="44">44</option>
                    <option value="45">45</option>
                    <option value="46">46</option>
                    <option value="47">47</option>
                    <option value="48">48</option>
                    <option value="49">49</option>
                    <option value="50">50</option>
                    <option value="51">51</option>
                    <option value="52">52</option>
                    <option value="53">53</option>
                    <option value="54">54</option>
                    <option value="55">55</option>
                    <option value="56">56</option>
                    <option value="57">57</option>
                    <option value="58">58</option>
                    <option value="59">59</option>
                </select>
                <script>
                    $(document).ready( function()
                    {
                        $('#question_answer_date_start_{$q.Question_id}').datepicker( { dateFormat: 'yy-mm-dd' } );
                        $('#question_answer_date_end_{$q.Question_id}').datepicker( { dateFormat: 'yy-mm-dd' } );
                    } );
                </script>
                </div>
            {/if}

            {if $q.id_Question_type == 6}
                <div>
                    <input type="text" id="question_answer_timestamp_{$q.Question_id}">
                    <select name="question_answer_timestamp_hour_{$q.Question_id}" id="question_answer_timestamp_hour_{$q.Question_id}">
                        <option value="00">00</option>
                        <option value="01">01</option>
                        <option value="02">02</option>
                        <option value="03">03</option>
                        <option value="04">04</option>
                        <option value="05">05</option>
                        <option value="06">06</option>
                        <option value="07">07</option>
                        <option value="08">08</option>
                        <option value="09">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                    </select>
                    <select name="question_answer_timestamp_minute_{$q.Question_id}" id="question_answer_timestamp_minute_{$q.Question_id}">
                        <option value="00">00</option>
                        <option value="01">01</option>
                        <option value="02">02</option>
                        <option value="03">03</option>
                        <option value="04">04</option>
                        <option value="05">05</option>
                        <option value="06">06</option>
                        <option value="07">07</option>
                        <option value="08">08</option>
                        <option value="09">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                        <option value="24">24</option>
                        <option value="25">25</option>
                        <option value="26">26</option>
                        <option value="27">27</option>
                        <option value="28">28</option>
                        <option value="29">29</option>
                        <option value="30">30</option>
                        <option value="31">31</option>
                        <option value="32">32</option>
                        <option value="33">33</option>
                        <option value="34">34</option>
                        <option value="35">35</option>
                        <option value="36">36</option>
                        <option value="37">37</option>
                        <option value="38">38</option>
                        <option value="39">39</option>
                        <option value="40">40</option>
                        <option value="41">41</option>
                        <option value="42">42</option>
                        <option value="43">43</option>
                        <option value="44">44</option>
                        <option value="45">45</option>
                        <option value="46">46</option>
                        <option value="47">47</option>
                        <option value="48">48</option>
                        <option value="49">49</option>
                        <option value="50">50</option>
                        <option value="51">51</option>
                        <option value="52">52</option>
                        <option value="53">53</option>
                        <option value="54">54</option>
                        <option value="55">55</option>
                        <option value="56">56</option>
                        <option value="57">57</option>
                        <option value="58">58</option>
                        <option value="59">59</option>
                    </select>
                    <script>
                        $(document).ready( function()
                        {
                            $('#question_answer_timestamp_{$q.Question_id}').datepicker( { dateFormat: 'yy-mm-dd' } );
                        } );
                    </script>
                </div>
            {/if}

            {if $q.id_Question_type == 7}
                <div class="question_add_answer">
                    <input type="text" id="question_answer_timestamp_date_{$q.Question_id}" name="question_answer_timestamp_date_{$q.Question_id}">
                    <script>
                        $(document).ready( function()
                        {
                            $('#question_answer_timestamp_date_{$q.Question_id}').datepicker( { dateFormat: 'yy-mm-dd' } );
                        } );
                    </script>
                </div>
            {/if}

            <script>
                $(document).ready( function()
                {
                    //Set everything to ok
                    $('#question_answer_{$q.Question_id}').blur( $.fn.filter_set_ok );

                    $('#question_answer_timestamp_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_timestamp_{$q.Question_id}', '#question_answer_timestamp_hour_{$q.Question_id}', '#question_answer_timestamp_minute_{$q.Question_id}', '#question_answer_timestamp_date_{$q.Question_id}' ) ) } );
                    $('#question_answer_timestamp_hour_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_timestamp_{$q.Question_id}', '#question_answer_timestamp_hour_{$q.Question_id}', '#question_answer_timestamp_minute_{$q.Question_id}', '#question_answer_timestamp_date_{$q.Question_id}' ) ) } );
                    $('#question_answer_timestamp_minute_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_timestamp_{$q.Question_id}', '#question_answer_timestamp_hour_{$q.Question_id}', '#question_answer_timestamp_minute_{$q.Question_id}', '#question_answer_timestamp_date_{$q.Question_id}' ) ) } );
                    $('#question_answer_timestamp_date_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_timestamp_{$q.Question_id}', '#question_answer_timestamp_hour_{$q.Question_id}', '#question_answer_timestamp_minute_{$q.Question_id}', '#question_answer_timestamp_date_{$q.Question_id}' ) ) } );

                    $('#question_answer_date_start_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_start_{$q.Question_id}', '#question_answer_date_start_hour_{$q.Question_id}', '#question_answer_date_start_minute_{$q.Question_id}' ) ) } );
                    $('#question_answer_date_start_hour_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_start_{$q.Question_id}', '#question_answer_date_start_hour_{$q.Question_id}', '#question_answer_date_start_minute_{$q.Question_id}' ) ) } );
                    $('#question_answer_date_start_minute_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_start_{$q.Question_id}', '#question_answer_date_start_hour_{$q.Question_id}', '#question_answer_date_start_minute_{$q.Question_id}' ) ) } );

                    $('#question_answer_date_end_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_end_{$q.Question_id}', '#question_answer_date_end_hour_{$q.Question_id}', '#question_answer_date_end_minute_{$q.Question_id}' ) ) } );
                    $('#question_answer_date_end_hour_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_end_{$q.Question_id}', '#question_answer_date_end_hour_{$q.Question_id}', '#question_answer_date_end_minute_{$q.Question_id}' ) ) } );
                    $('#question_answer_date_end_minute_{$q.Question_id}').change( function() { $.fn.filter_set_ok( new Array( '#question_answer_date_end_{$q.Question_id}', '#question_answer_date_end_hour_{$q.Question_id}', '#question_answer_date_end_minute_{$q.Question_id}' ) ) } );

                    // Activating filters on the question
                    {if $q.Filters->email_enabled}
                        $('#question_answer_{$q.Question_id}').blur( $.fn.filter_check_email );
                    {/if}

                    {if $q.Filters->charlimit_enabled}
                        $('#question_answer_{$q.Question_id}').keyup( function( e ){ $.fn.filter_check_charlimit_keyup( {$q.Filters->charlimit}, $(this), e ) } );
                        $('#question_answer_{$q.Question_id}').blur( function( e ){ $.fn.filter_check_charlimit_blur( {$q.Filters->charlimit}, $(this), e ) } );
                    {/if}

                    {if $q.Filters->charpool_enabled}
                        $('#question_answer_{$q.Question_id}').keyup( function( e ){ $.fn.filter_check_charpool_keyup( '{$q.Filters->charpool}', $(this), e ) } );
                    {/if}

                    {if $q.Filters->minimum_enabled}
                        $('#question_answer_{$q.Question_id}').blur( function( e ){ $.fn.filter_check_minimum_blur( {$q.Filters->minimum}, $(this), e ) } );
                    {/if}

                    {if $q.Filters->maximum_enabled}
                        $('#question_answer_{$q.Question_id}').blur( function( e ){ $.fn.filter_check_maximum_blur( {$q.Filters->maximum}, $(this), e ) } );
                    {/if}

                    {if $q.Filters->minimum_date_enabled}
                        var minimum_date = '{$q.Filters->minimum_date}';
                        var minimum_date_parts = minimum_date.split( '-' );
                        var minimum_date_year = parseInt( minimum_date_parts[0], 10 );
                        var minimum_date_month = parseInt( minimum_date_parts[1], 10 );
                        var minimum_date_day = parseInt( minimum_date_parts[2], 10 );
                        var minimum_date_hour = parseInt( '{if $q.Filters->minimum_date_hour}{$q.Filters->minimum_date_hour}{else}0{/if}', 10 );
                        var minimum_date_minute = parseInt( '{if $q.Filters->minimum_date_minute}{$q.Filters->minimum_date_minute}{else}0{/if}', 10 );

                        var minimum_date_month_string = minimum_date_month;
                        if ( minimum_date_month_string <= 9 )
                        {
                            minimum_date_month_string = String( '0' + minimum_date_month_string );
                        }
                        else
                        {
                            minimum_date_month_string = String( minimum_date_month_string );
                        }

                        var minimum_date_day_string = minimum_date_day;
                        if ( minimum_date_day_string <= 9 )
                        {
                            minimum_date_day_string = String( '0' + minimum_date_day_string );
                        }
                        else
                        {
                            minimum_date_day_string = String( minimum_date_day_string );
                        }

                        {if $q.id_Question_type == 5}
                            $('#question_answer_date_start_{$q.Question_id}').datepicker( "option", "minDate", new Date( minimum_date_year, minimum_date_month - 1, minimum_date_day, minimum_date_hour, minimum_date_minute ) );
                            $('#question_answer_date_end_{$q.Question_id}').datepicker( "option", "minDate", new Date( minimum_date_year, minimum_date_month - 1, minimum_date_day, minimum_date_hour, minimum_date_minute ) );

                            $('#question_answer_date_start_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_start_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_start_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                            
                            $('#question_answer_date_end_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                            
                            $('#question_answer_date_end_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_end_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                            
                        {/if}


                        {if $q.id_Question_type == 6}
                            $('#question_answer_timestamp_{$q.Question_id}').datepicker( "option", "minDate", new Date( minimum_date_year, minimum_date_month - 1, minimum_date_day, minimum_date_hour, minimum_date_minute ) );

                            $('#question_answer_timestamp_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_timestamp_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_timestamp_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_minimum_hour_minute( 
                                        String( minimum_date_year ) + '-' + minimum_date_month_string + '-' + minimum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        minimum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        minimum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                        {/if}

                        $('#question_answer_timestamp_{$q.Question_id}').datepicker( "option", "minDate", new Date( minimum_date_year, minimum_date_month - 1, minimum_date_day, minimum_date_hour, minimum_date_minute ) );

                        $('#question_answer_timestamp_date_{$q.Question_id}').datepicker( "option", "minDate", new Date( minimum_date_year, minimum_date_month - 1, minimum_date_day, minimum_date_hour, minimum_date_minute ) );
                    {/if}

                    {if $q.Filters->maximum_date_enabled}
                        var maximum_date = '{$q.Filters->maximum_date}';
                        var maximum_date_parts = maximum_date.split( '-' );
                        var maximum_date_year = parseInt( maximum_date_parts[0], 10 );
                        var maximum_date_month = parseInt( maximum_date_parts[1], 10 );
                        var maximum_date_day = parseInt( maximum_date_parts[2], 10 );
                        var maximum_date_hour = parseInt( '{if isset($q.Filters->maximum_date_hour)}{$q.Filters->maximum_date_hour}{else}0{/if}', 10 );
                        var maximum_date_minute = parseInt( '{if isset($q.Filters->maximum_date_minute)}{$q.Filters->maximum_date_minute}{else}0{/if}', 10 );

                        var maximum_date_month_string = maximum_date_month;
                        if ( maximum_date_month_string <= 9 )
                        {
                            maximum_date_month_string = String( '0' + maximum_date_month_string );
                        }
                        else
                        {
                            maximum_date_month_string = String( maximum_date_month_string );
                        }

                        var maximum_date_day_string = maximum_date_day;
                        if ( maximum_date_day_string <= 9 )
                        {
                            maximum_date_day_string = String( '0' + maximum_date_day_string );
                        }
                        else
                        {
                            maximum_date_day_string = String( maximum_date_day_string );
                        }

                        {if $q.id_Question_type == 5}
                            $('#question_answer_date_start_{$q.Question_id}').datepicker( "option", "maxDate", new Date( maximum_date_year, maximum_date_month - 1, maximum_date_day, maximum_date_hour, maximum_date_minute ) );
                            $('#question_answer_date_end_{$q.Question_id}').datepicker( "option", "maxDate", new Date( maximum_date_year, maximum_date_month - 1, maximum_date_day, maximum_date_hour, maximum_date_minute ) );

                            $('#question_answer_date_start_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_start_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_start_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_start_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_start_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_start_minute_{$q.Question_id}')
                                    );
                                }
                            );
                            
                            $('#question_answer_date_end_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    );
                                }
                            );
                            
                            $('#question_answer_date_end_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_date_end_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_date_end_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_date_end_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_date_end_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                            
                        {/if}

                        {if $q.id_Question_type == 6}
                            $('#question_answer_timestamp_{$q.Question_id}').datepicker( "option", "maxDate", new Date( maximum_date_year, maximum_date_month - 1, maximum_date_day, maximum_date_hour, maximum_date_minute ) );
                            
                            $('#question_answer_timestamp_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                            
                            $('#question_answer_timestamp_hour_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );

                            $('#question_answer_timestamp_minute_{$q.Question_id}').change( 
                                function( e ) 
                                { 
                                    $.fn.filter_maximum_hour_minute( 
                                        String( maximum_date_year ) + '-' + maximum_date_month_string + '-' + maximum_date_day_string, 
                                        $('#question_answer_timestamp_{$q.Question_id}'),
                                        maximum_date_hour,
                                        $('#question_answer_timestamp_hour_{$q.Question_id}'),
                                        maximum_date_minute,
                                        $('#question_answer_timestamp_minute_{$q.Question_id}')
                                    ); 
                                } 
                            );
                        {/if}



                        $('#question_answer_timestamp_date_{$q.Question_id}').datepicker( "option", "maxDate", new Date( maximum_date_year, maximum_date_month - 1, maximum_date_day, maximum_date_hour, maximum_date_minute ) );
                    {/if}

                    
                } );
            </script>

            {if $q.Filters->observations_enabled}                
                <div id="question_observations_{$q.Question_id}">
                    {$q.Filters->observations}
                </div>
            {/if}

        </div>
    {/foreach}

    <input type="submit" value="Send">
    
</form>

